package com.dreem.flyweight;

import java.util.HashMap;

/**
 * @program: DesignParrtern
 * @description: 网站工厂类
 * @author: Peng
 * @create: 2021-02-24  19:20
 **/
public class WebSiteFactory {
    private final HashMap<String, WebSite> POOL;

    private WebSiteFactory(){
        this.POOL = new HashMap<>();
    }

    public static WebSiteFactory getInstance(){
        return new WebSiteFactory();
    }

    public WebSite getWebSiteGategory(String type){
        if(!this.POOL.containsKey(type)){
            this.POOL.put(type, new ConcreteWebSite(type));
        }
        return this.POOL.get(type);
    }

    public int getSize(){
        return POOL.size();
    }
}
